<?php
namespace App\Traits;

use App\Models\FakeDetail;
use App\Models\FakeList;
use Illuminate\Http\Request;

Trait Trait99_102 {

    public function robotStatus()
    {
        $data = FakeList::with(['details' => function ($query) {
            $query->select(["f_id", "extra_data"]);
        }])->select(['id', 'name', 'extra_data'])->wherein('id', [123, 124, 125, 126])->get();
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

    /**
     * @return void
     */
    public function robotDetail(Request $request)
    {
        $input = $request->validate([
            'id' => "required",
            'monitor' => "required",
        ]);
        $data = FakeDetail::where(['f_id' => $input['id']])->update([
            'extra_data->实时监控' => $input['monitor'],
        ]);
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }


}
